package com.example.a2207_zh.mvvm

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModelProvider
import com.example.a2207_zh.R

abstract class BaseActivity<VDB:ViewDataBinding,VM:BaseViewModel> : AppCompatActivity(){
    lateinit var binding:VDB
    lateinit var viewModel:VM

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this,getLayout())
        viewModel = ViewModelProvider(this)[getViewModel()]
        initView()
        initData()
    }

    abstract fun getLayout():Int
    abstract fun getViewModel():Class<VM>
    abstract fun initView()
    abstract fun initData()
}